package routes

import (
	"gitee.com/iswleii/wechat-weather/controllers"
	"gitee.com/iswleii/wechat-weather/logger"
	"net/http"

	"github.com/gin-gonic/gin"
)

func Setup(mode string) *gin.Engine {

	// 控制 gin 框架的打印信息
	if mode == gin.ReleaseMode {
		gin.SetMode(gin.ReleaseMode)
	}

	r := gin.New()
	r.Use(logger.GinLogger(), logger.GinRecovery(true))

	// 首页
	r.GET("/", func(c *gin.Context) {
		c.String(http.StatusOK, "gin web temp")
	})

	// 测试接口
	r.GET("/ping", func(c *gin.Context) {
		c.String(http.StatusOK, "pong")
	})

	r.GET("/hi", controllers.Hello)

	return r
}
